//
//  LGConsultRecordCell.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/10/8.
//

#import "LGConsultRecordCell.h"

@interface LGConsultRecordCell()

/**   */
@property (nonatomic , strong)UIView *lineView;
/**   */
@property (nonatomic , strong)UILabel *dateLabel;
/**   */
@property (nonatomic , strong)UIView *baseView;
/**   */
@property (nonatomic , strong)UIImageView *iconView;
/**   */
@property (nonatomic , strong)UILabel *titleLabel;
/**   */
@property (nonatomic , strong)UILabel *nameLabel;
/**   */
@property (nonatomic , strong)UILabel *needTitle;
/**   */
@property (nonatomic , strong)UILabel *needLabel;
/**   */
@property (nonatomic , strong)UILabel *descTitle;
/**   */
@property (nonatomic , strong)UILabel *descLabel;
/**   */
@property (nonatomic , strong)UILabel *hospitalTitle;
/**   */
@property (nonatomic , strong)UILabel *hospitalLabel;

@end

@implementation LGConsultRecordCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubView];
    }
    return  self;
}

-(void)setDataDic:(NSDictionary *)dataDic{
    _dataDic = dataDic;
    NSDictionary *iconDic = @{@"0":@"咨询记录-慢病复查",@"1":@"咨询记录-线下复查",@"2":@"咨询记录-视频咨询",@"3":@"咨询记录-专家咨询",@"4":@"咨询记录-团队咨询",@"5":@"咨询记录-运动测试",@"6":@"咨询记录-电话咨询"};
    NSString *type = LGNSString(dataDic[@"appointment_type"]);
    self.iconView.image = [UIImage imageNamed:iconDic[type]];
    self.dateLabel.text = LGNSString(dataDic[@"visit_date"]);
    self.titleLabel.text = LGNSString(dataDic[@"type_title"]);
    self.nameLabel.text = LGNSString(dataDic[@"doctor_name"]);
    NSString *needStr = LGNSString(dataDic[@"consultation_demands"]);
    NSString *descStr = LGNSString(dataDic[@"situation"]);
    NSString *hospitalStr = LGNSString(dataDic[@"visit_address_short"]);
    CGFloat needTop = (needStr.length>0)?viewPix(8):0;
    CGFloat descTop = (descStr.length>0)?viewPix(8):0;
    CGFloat hospTop = (hospitalStr.length>0)?viewPix(8):0;
    self.needTitle.text = (needStr.length>0)?@"问诊需求":@"";
    self.descTitle.text = (descStr.length>0)?@"病情描述":@"";
    self.hospitalTitle.text = (hospitalStr.length>0)?@"测试院区":@"";
    self.needLabel.text = needStr;
    self.descLabel.text = descStr;
    self.hospitalLabel.text = hospitalStr;
    [self.needTitle mas_updateConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.titleLabel.mas_bottom).offset(needTop);
    }];
    [self.descTitle mas_updateConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.needLabel.mas_bottom).offset(descTop);
    }];
    [self.hospitalTitle mas_updateConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.descLabel.mas_bottom).offset(hospTop);
    }];
}


#pragma mark
#pragma mark ====> 创建控件
-(void)createSubView{
    self.clipsToBounds = YES;
    self.backgroundColor = [UIColor clearColor];
    self.contentView.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.lineView];
    [self.contentView addSubview:self.dateLabel];
    [self.contentView addSubview:self.baseView];
    [self.baseView addSubview:self.iconView];
    [self.baseView addSubview:self.titleLabel];
    [self.baseView addSubview:self.nameLabel];
    [self.baseView addSubview:self.needTitle];
    [self.baseView addSubview:self.needLabel];
    [self.baseView addSubview:self.descTitle];
    [self.baseView addSubview:self.descLabel];
    [self.baseView addSubview:self.hospitalTitle];
    [self.baseView addSubview:self.hospitalLabel];
    
    [self.dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.lineView.mas_right).offset(viewPix(12));
        make.centerY.equalTo(self.lineView);
    }];
    [self.baseView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(viewPix(16));
        make.right.equalTo(self.contentView).offset(-viewPix(16));
        make.top.equalTo(self.lineView.mas_bottom).offset(viewPix(8));
        make.bottom.equalTo(self.contentView).offset(-viewPix(10));
    }];
    [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.baseView).offset(viewPix(12));
        make.top.equalTo(self.baseView).offset(viewPix(16));
        make.width.height.equalTo(@(viewPix(20)));
    }];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.iconView.mas_right).offset(viewPix(8));
        make.centerY.equalTo(self.iconView);
    }];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.titleLabel.mas_right).offset(viewPix(8));
        make.centerY.equalTo(self.iconView);
    }];
    [self.needTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.titleLabel.mas_bottom).offset(0);
        make.left.equalTo(self.titleLabel);
        make.width.equalTo(@(65));
    }];
    [self.needLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.needTitle.mas_right);
        make.right.equalTo(self.baseView).offset(-viewPix(10));
        make.top.equalTo(self.needTitle);
    }];
    [self.descTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.needLabel.mas_bottom).offset(0);
        make.left.width.equalTo(self.needTitle);
    }];
    [self.descLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.descTitle);
        make.left.right.equalTo(self.needLabel);
    }];
    
    [self.hospitalTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.descLabel.mas_bottom).offset(0);
        make.left.width.equalTo(self.needTitle);
    }];
    [self.hospitalLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.hospitalTitle);
        make.left.right.equalTo(self.needLabel);
        make.bottom.equalTo(self.baseView).offset(-viewPix(16));
    }];
    
}
-(UIView *)lineView{
    if(!_lineView){
        _lineView = [[UIView alloc] initWithFrame:CGRectMake(viewPix(16), viewPix(8), 4, viewPix(14))];
        _lineView.backgroundColor = [UIColor colorWithString:@"#77D4C6"];
        _lineView.cornerRidus = 2;
    }
    return _lineView;
}

-(UILabel *)dateLabel{
    if(!_dateLabel){
        _dateLabel = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFontWeight(14, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _dateLabel;
}

-(UIView *)baseView{
    if(!_baseView){
        _baseView = [[UIView alloc] init];
        _baseView.backgroundColor = [UIColor whiteColor];
        _baseView.cornerRidus = 15;
    }
    return _baseView;
}

-(UIImageView *)iconView{
    if(!_iconView){
        _iconView = [[UIImageView alloc]init];
    }
    return _iconView;
}

-(UILabel *)titleLabel{
    if(!_titleLabel){
        _titleLabel = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFontWeight(15, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _titleLabel;
}

-(UILabel *)nameLabel{
    if(!_nameLabel){
        _nameLabel = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFontWeight(15, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _nameLabel;
}

-(UILabel *)needTitle{
    if(!_needTitle){
        _needTitle = [UILabel lableWithText:@"问诊需求" colorString:@"#666666" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _needTitle;
}

-(UILabel *)needLabel{
    if(!_needLabel){
        _needLabel = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:0];
    }
    return _needLabel;
}


-(UILabel *)descTitle{
    if(!_descTitle){
        _descTitle = [UILabel lableWithText:@"病情描述" colorString:@"#666666" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _descTitle;
}

-(UILabel *)descLabel{
    if(!_descLabel){
        _descLabel = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:0];
    }
    return _descLabel;
}


-(UILabel *)hospitalTitle{
    if(!_hospitalTitle){
        _hospitalTitle = [UILabel lableWithText:@"测试医院" colorString:@"#666666" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _hospitalTitle;
}

-(UILabel *)hospitalLabel{
    if(!_hospitalLabel){
        _hospitalLabel = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:0];
    }
    return _hospitalLabel;
}
@end
